export const indexMixin = {
  data() {
    return {
      listLoading: false,
      searchlist: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleSearchSubmit(params) {
      this.searchData = { ...this.searchData, ...params, pageNum: 1 }
      this.getList()
    },
    // 更新列表
    update(params) {
      if (params) {
        this.searchData = { ...this.searchData, ...params }
      }
      const { searchlist, searchData: { total, pageSize }} = this
      if (searchlist.length === 1 && total > pageSize) {
        this.searchData.pageNum -= 1
      }
      this.getList()
    },
    /**
     * pageSize 变更
     */
    updatePage({ page, limit }) {
      this.searchData.pageNum = page
      this.searchData.pageSize = limit
      this.getList()
    }
  }
}
